package quicksort

//快速排序
func Quicksort(arr []int) []int {
	var length = len(arr)
	if length == 0 || length == 1 {
		return arr
	} else {
		var left = make([]int, 0)
		var right = make([]int, 0)
		for i := 1; i < length; i++ {
			if arr[i] <= arr[0] {
				left = append(left, arr[i])
			} else {
				right = append(right, arr[i])
			}
		}
		return append(append(Quicksort(left), arr[0]), Quicksort(right)...)
	}
}
